public class Solution {
    public int findJudge(int n, int[][] trust) {
        int[] outDeg = new int[n+1];    //出度
        int[] inDef = new int[n+1];     //入度

        //遍历数组
        for (int i = 0; i < trust.length; i++) {
            outDeg[trust[i][0]]++;
            inDef[trust[i][1]]++;
        }
        //查看结果
        for (int i = 1; i <= n; i++) {
            if(outDeg[i]==0 && inDef[i]==n-1){
                return i;
            }
        }

        return -1;
    }
}
